package cn.quickcode.monitor.ui.provider;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.eclipse.ui.console.MessageConsoleStream;

import cn.quickcode.monitor.ui.part.ConsoleViewPart;

public class SMConsoleProvider
{
	public static SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	public synchronized static void println(String message)
	{
		MessageConsoleStream stream = ConsoleViewPart.getConsole().newMessageStream();
		stream.print(df.format(new Date()));
		stream.print(" : ");
		stream.println(message);
		try
		{
			stream.flush();
			stream.close();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}

	public synchronized static void print(String message)
	{
		MessageConsoleStream stream = ConsoleViewPart.getConsole().newMessageStream();
		stream.print(df.format(new Date()));
		stream.print(" : ");
		stream.print(message);
		try
		{
			stream.flush();
			stream.close();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
}
